﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using cancerportal.Data;

namespace cancerportal.Models
{
    public class corpusModels : DataBaseConnection
    {
        public static int countNumberWord(string word)
        {
            int test = 0;
            string query = "select * from cancerportal.dbo.corpus where lexical_content = @word";
            try
            {
                open();
                DBCommand.CommandText = query;
                DBCommand.Parameters.AddWithValue("@word", word);
                reader = DBCommand.ExecuteReader();
                while (reader.Read())
                {
                    test = test + 1;
                }
            }
            finally
            {
                close();
            }
            return test;
        }

        public static void insertIntoDB(string newWord)
        {
            string query = "insert into cancerportal.dbo.corpus(lexical_content) values (@content)";
            try
            {
                open();
                DBCommand.CommandText = query;
                DBCommand.Parameters.AddWithValue("@content", newWord);
                DBCommand.ExecuteNonQuery();
            }
            finally
            {
                close();
            }
        }
    }
}